<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
 </tr>
 </tbody>
</table>
</div>
<body bgcolor="#ffffff">
<table width="100%">
  <tr>
    <td width="30%" align="left" valign="center">
      <a href="https://github.com/open-source-parsers/jsoncpp">
      JsonCpp project page
      </a>
    </td>
    <td width="20%" align="center" valign="center">
      <a href="hierarchy.html">
        Classes
      </a>
    </td>
    <td width="20%" align="center" valign="center">
      <a href="namespace_json.html">
        Namespace
      </a>
    </td>
    <td width="30%" align="right" valign="center">
      <a href="http://open-source-parsers.github.io/jsoncpp-docs/doxygen/">JsonCpp home page</a>
    </td>
  </tr>
</table>
<hr>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',false,false,'search.php','Search');
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('index.html','');});
</script>
<div id="doc-content">
<div class="header">
  <div class="headertitle">
<div class="title">JsonCpp Documentation</div>  </div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h1><a class="anchor" id="_intro"></a>
Introduction</h1>
<p><a href="http://www.json.org/">JSON (JavaScript Object Notation)</a> is a lightweight data-interchange format.</p>
<p>Here is an example of JSON data: </p><pre class="fragment">{
    "encoding" : "UTF-8",
    "plug-ins" : [
        "python",
        "c++",
        "ruby"
        ],
    "indent" : { "length" : 3, "use_space": true }
}
</pre><p> <b>JsonCpp</b> supports comments as <em>meta-data</em>: </p><div class="fragment"><div class="line"><span class="comment">// Configuration options</span></div><div class="line">{</div><div class="line">    <span class="comment">// Default encoding for text</span></div><div class="line">    <span class="stringliteral">&quot;encoding&quot;</span> : <span class="stringliteral">&quot;UTF-8&quot;</span>,</div><div class="line">    </div><div class="line">    <span class="comment">// Plug-ins loaded at start-up</span></div><div class="line">    <span class="stringliteral">&quot;plug-ins&quot;</span> : [</div><div class="line">        <span class="stringliteral">&quot;python&quot;</span>,</div><div class="line">        <span class="stringliteral">&quot;c++&quot;</span>,  <span class="comment">// trailing comment</span></div><div class="line">        <span class="stringliteral">&quot;ruby&quot;</span></div><div class="line">        ],</div><div class="line">        </div><div class="line">    <span class="comment">// Tab indent size</span></div><div class="line">    <span class="comment">// (multi-line comment)</span></div><div class="line">    <span class="stringliteral">&quot;indent&quot;</span> : { <span class="comment">/*embedded comment*/</span> <span class="stringliteral">&quot;length&quot;</span> : 3, <span class="stringliteral">&quot;use_space&quot;</span>: <span class="keyword">true</span> }</div><div class="line">}</div></div><!-- fragment --><h1><a class="anchor" id="_features"></a>
Features</h1>
<ul>
<li>read and write JSON document</li>
<li>attach C++ style comments to element during parsing</li>
<li>rewrite JSON document preserving original comments</li>
</ul>
<p>Notes: Comments used to be supported in JSON but were removed for portability (C like comments are not supported in Python). Since comments are useful in configuration/input file, this feature was preserved.</p>
<h1><a class="anchor" id="_example"></a>
Code example</h1>
<div class="fragment"><div class="line"><a class="code" href="class_json_1_1_value.html">Json::Value</a> root;   <span class="comment">// &#39;root&#39; will contain the root value after parsing.</span></div><div class="line">std::cin &gt;&gt; root;</div><div class="line"></div><div class="line"><span class="comment">// You can also read into a particular sub-value.</span></div><div class="line">std::cin &gt;&gt; root[<span class="stringliteral">&quot;subtree&quot;</span>];</div><div class="line"></div><div class="line"><span class="comment">// Get the value of the member of root named &#39;encoding&#39;,</span></div><div class="line"><span class="comment">// and return &#39;UTF-8&#39; if there is no such member.</span></div><div class="line">std::string encoding = root.<a class="code" href="class_json_1_1_value.html#a034eb7bf85a44fa759bdaa232788ca66">get</a>(<span class="stringliteral">&quot;encoding&quot;</span>, <span class="stringliteral">&quot;UTF-8&quot;</span> ).<a class="code" href="class_json_1_1_value.html#ab0d86bf425efefd03513e8dbfaca317b">asString</a>();</div><div class="line"></div><div class="line"><span class="comment">// Get the value of the member of root named &#39;plug-ins&#39;; return a &#39;null&#39; value if</span></div><div class="line"><span class="comment">// there is no such member.</span></div><div class="line"><span class="keyword">const</span> <a class="code" href="class_json_1_1_value.html">Json::Value</a> plugins = root[<span class="stringliteral">&quot;plug-ins&quot;</span>];</div><div class="line"></div><div class="line"><span class="comment">// Iterate over the sequence elements.</span></div><div class="line"><span class="keywordflow">for</span> ( <span class="keywordtype">int</span> index = 0; index &lt; plugins.<a class="code" href="class_json_1_1_value.html#a0ec2808e1d7efa4e9fad938d6667be44">size</a>(); ++index )</div><div class="line">   loadPlugIn( plugins[index].asString() );</div><div class="line">   </div><div class="line"><span class="comment">// Try other datatypes. Some are auto-convertible to others.</span></div><div class="line">foo::setIndentLength( root[<span class="stringliteral">&quot;indent&quot;</span>].<span class="keyword">get</span>(<span class="stringliteral">&quot;length&quot;</span>, 3).asInt() );</div><div class="line">foo::setIndentUseSpace( root[<span class="stringliteral">&quot;indent&quot;</span>].<span class="keyword">get</span>(<span class="stringliteral">&quot;use_space&quot;</span>, <span class="keyword">true</span>).asBool() );</div><div class="line"></div><div class="line"><span class="comment">// Since Json::Value has an implicit constructor for all value types, it is not</span></div><div class="line"><span class="comment">// necessary to explicitly construct the Json::Value object.</span></div><div class="line">root[<span class="stringliteral">&quot;encoding&quot;</span>] = foo::getCurrentEncoding();</div><div class="line">root[<span class="stringliteral">&quot;indent&quot;</span>][<span class="stringliteral">&quot;length&quot;</span>] = foo::getCurrentIndentLength();</div><div class="line">root[<span class="stringliteral">&quot;indent&quot;</span>][<span class="stringliteral">&quot;use_space&quot;</span>] = foo::getCurrentIndentUseSpace();</div><div class="line"></div><div class="line"><span class="comment">// If you like the defaults, you can insert directly into a stream.</span></div><div class="line">std::cout &lt;&lt; root;</div><div class="line"><span class="comment">// Of course, you can write to `std::ostringstream` if you prefer.</span></div><div class="line"></div><div class="line"><span class="comment">// If desired, remember to add a linefeed and flush.</span></div><div class="line">std::cout &lt;&lt; std::endl;</div></div><!-- fragment --><h1><a class="anchor" id="_advanced"></a>
Advanced usage</h1>
<p>Configure <em>builders</em> to create <em>readers</em> and <em>writers</em>. For configuration, we use our own <code><a class="el" href="class_json_1_1_value.html" title="Represents a JSON value. ">Json::Value</a></code> (rather than standard setters/getters) so that we can add features without losing binary-compatibility.</p>
<div class="fragment"><div class="line"><span class="comment">// For convenience, use `writeString()` with a specialized builder.</span></div><div class="line"><a class="code" href="class_json_1_1_stream_writer_builder.html">Json::StreamWriterBuilder</a> wbuilder;</div><div class="line">wbuilder[<span class="stringliteral">&quot;indentation&quot;</span>] = <span class="stringliteral">&quot;\t&quot;</span>;</div><div class="line">std::string document = <a class="code" href="namespace_json.html#afd767fe4c7e962d0ff3d1a6d1622619f">Json::writeString</a>(wbuilder, root);</div><div class="line"></div><div class="line"><span class="comment">// Here, using a specialized Builder, we discard comments and</span></div><div class="line"><span class="comment">// record errors as we parse.</span></div><div class="line"><a class="code" href="class_json_1_1_char_reader_builder.html">Json::CharReaderBuilder</a> rbuilder;</div><div class="line">rbuilder[<span class="stringliteral">&quot;collectComments&quot;</span>] = <span class="keyword">false</span>;</div><div class="line">std::string errs;</div><div class="line"><span class="keywordtype">bool</span> ok = <a class="code" href="namespace_json.html#acfebeaf759a841173ddce34c4da22486">Json::parseFromStream</a>(rbuilder, std::cin, &amp;root, &amp;errs);</div></div><!-- fragment --><p>Yes, compile-time configuration-checking would be helpful, but <code><a class="el" href="class_json_1_1_value.html" title="Represents a JSON value. ">Json::Value</a></code> lets you write and read the builder configuration, which is better! In other words, you can configure your JSON parser using JSON.</p>
<p>CharReaders and StreamWriters are not thread-safe, but they are re-usable. </p><div class="fragment"><div class="line"><a class="code" href="class_json_1_1_char_reader_builder.html">Json::CharReaderBuilder</a> rbuilder;</div><div class="line">cfg &gt;&gt; rbuilder.<a class="code" href="class_json_1_1_char_reader_builder.html#ac69b7911ad64c171c51ebaf2ea26d958">settings_</a>;</div><div class="line">std::unique_ptr&lt;Json::CharReader&gt; <span class="keyword">const</span> reader(rbuilder.<a class="code" href="class_json_1_1_char_reader_builder.html#a963a9fdb280771f0801ac759da509649">newCharReader</a>());</div><div class="line">reader-&gt;parse(start, stop, &amp;value1, &amp;errs);</div><div class="line"><span class="comment">// ...</span></div><div class="line">reader-&gt;parse(start, stop, &amp;value2, &amp;errs);</div><div class="line"><span class="comment">// etc.</span></div></div><!-- fragment --><h1><a class="anchor" id="_pbuild"></a>
Build instructions</h1>
<p>The build instructions are located in the file <a href="https://github.com/open-source-parsers/jsoncpp/blob/master/README.md">README.md</a> in the top-directory of the project.</p>
<p>The latest version of the source is available in the project's GitHub repository: <a href="https://github.com/open-source-parsers/jsoncpp/">jsoncpp</a></p>
<h1><a class="anchor" id="_news"></a>
What's New?</h1>
<p>The description of latest changes can be found in <a href="https://github.com/open-source-parsers/jsoncpp/wiki/NEWS">the NEWS wiki </a>.</p>
<h1><a class="anchor" id="_rlinks"></a>
Related links</h1>
<ul>
<li><a href="http://www.json.org/">JSON</a> Specification and alternate language implementations.</li>
<li><a href="http://www.yaml.org/">YAML</a> A data format designed for human readability.</li>
<li><a href="http://www.cl.cam.ac.uk/~mgk25/unicode.html">UTF-8 and Unicode FAQ</a>.</li>
</ul>
<h1><a class="anchor" id="_plinks"></a>
Old project links</h1>
<ul>
<li><a href="https://sourceforge.net/projects/jsoncpp/">https://sourceforge.net/projects/jsoncpp/</a></li>
<li><a href="http://jsoncpp.sourceforge.net">http://jsoncpp.sourceforge.net</a></li>
<li><a href="http://sourceforge.net/projects/jsoncpp/files/">http://sourceforge.net/projects/jsoncpp/files/</a></li>
<li><a href="http://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/">http://jsoncpp.svn.sourceforge.net/svnroot/jsoncpp/trunk/</a></li>
<li><a href="http://jsoncpp.sourceforge.net/old.html">http://jsoncpp.sourceforge.net/old.html</a></li>
</ul>
<h1><a class="anchor" id="_license"></a>
License</h1>
<p>See file <a href="https://github.com/open-source-parsers/jsoncpp/blob/master/LICENSE"><code>LICENSE</code></a> in the top-directory of the project.</p>
<p>Basically JsonCpp is licensed under MIT license, or public domain if desired and recognized in your jurisdiction.</p>
<dl class="section author"><dt>Author</dt><dd>Baptiste Lepilleur <a href="#" onclick="location.href='mai'+'lto:'+'ble'+'p@'+'use'+'rs'+'.so'+'ur'+'cef'+'or'+'ge.'+'ne'+'t'; return false;">blep@<span style="display: none;">.nosp@m.</span>user<span style="display: none;">.nosp@m.</span>s.sou<span style="display: none;">.nosp@m.</span>rcef<span style="display: none;">.nosp@m.</span>orge.<span style="display: none;">.nosp@m.</span>net</a> (originator) </dd>
<dd>
Christopher Dunn <a href="#" onclick="location.href='mai'+'lto:'+'cdu'+'nn'+'200'+'1@'+'gma'+'il'+'.co'+'m'; return false;">cdunn<span style="display: none;">.nosp@m.</span>2001<span style="display: none;">.nosp@m.</span>@gmai<span style="display: none;">.nosp@m.</span>l.co<span style="display: none;">.nosp@m.</span>m</a> (primary maintainer) </dd></dl>
<dl class="section version"><dt>Version</dt><dd><div class="fragment"><div class="line">1.8.3</div></div><!-- fragment --> We make strong guarantees about binary-compatibility, consistent with <a href="http://apr.apache.org/versioning.html">the Apache versioning scheme</a>. </dd></dl>
<dl class="section see"><dt>See also</dt><dd><a class="el" href="version_8h.html">version.h</a> </dd></dl>
</div></div><!-- contents -->
</div><!-- doc-content -->
<!-- HTML footer for doxygen 1.8.13-->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="footer">Generated by
    <a href="http://www.doxygen.org/index.html">
    <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.13 </li>
  </ul>
</div>
</body>
</html>
